<script setup>
import { ref } from "vue";
import { getComplaintList } from "@/api/feedback";
import Pagination from "@/components/Pagination/index.vue";

const list = ref([]);
const loading = ref(false);
getComplaintListFn();
async function getComplaintListFn() {
  loading.value = true;
  const res = await getComplaintList();
  loading.value = false;
  console.log(res);
  list.value = res.data;
}
</script>

<template>
  <div class="container">
    <p class="title">投诉建议</p>
    <div class="box">
      <el-table
        size="small"
        v-loading="loading"
        :data="list.data"
        style="width: 100%"
        row-key="id"
      >
        <el-table-column prop="id" label="ID" width="80" />
        <el-table-column label="创建时间">
          <template v-slot="scope">
            <p>{{ scope.row.created_at }}</p>
          </template>
        </el-table-column>
        <el-table-column label="用户资料">
          <template v-slot="scope">
            <p class="font-bold">{{ scope.row.user.name }}</p>
            <p>用户ID：{{ scope.row.user.id }}</p>
            <p>{{ scope.row.user.mobile }}</p>
          </template>
        </el-table-column>
        <el-table-column label="详情">
          <template v-slot="scope">
            <el-tooltip
              :disabled="disabled"
              :content="scope.row.detail ? scope.row.detail : '/'"
              placement="bottom"
              effect="light"
            >
              {{ scope.row.detail ? scope.row.detail.substring(0, 5) + "..." : "/" }}
            </el-tooltip>
          </template>
        </el-table-column>
      </el-table>
      <Pagination :total="list.total" :page="list.current_page" />
    </div>
  </div>
</template>
